<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>登录</title>
</head>

<body>
    <a href="javascript:">正在登录，点击此处可直接跳转</a>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/2.2.0/socket.io.dev.js"></script>
    <script>
        var code = location.search.split("&")[0].split("=")[1]
        var state = location.search.split("&")[1].split("=")[1]
        var socket = io('http://127.0.0.1:5000', {
            query: {
                code,
                state
            },
            transports: ['websocket']
        }) //已经连接上

        socket.emit("loginGithub")

        socket.on("res",(data)=>{
            if(data !== "error"){
                window.close()
            }
        })
        var link = document.getElementsByTagName("a")[0] 
        link.onclick = function(){
            socket.emit("loginGithub")
            window.close()
        }
    </script>
</body>

</html>